<?php
require_once 'models/models_loaihang.php';
$oblh=new models_loaihang();
require_once 'models/models_thongke.php';
$obtk=new models_thongke();
$p=new pagertk();//khoi tao doi tuong pager
if(isset($_GET['mod'])){
	switch ($_GET['mod']){
		case 'tonkho':{
			$limit=7;
			$count=$obtk->tongsodong();
			$start=$p->findstart($limit);
			$page=$p->findpages($count,$limit);
			$data['listmh'] = $obtk->danhsachmh($start, $limit);
			$pagelist=$p->pagelist($_GET['page'],$page);
			$data['listlh']=$oblh->listLoaiHang();
			
			require_once 'views/admin/thongke/tonkho.php';
			break;
		}
		case 'tkdoanhthu':{
			if(isset($_POST['tunam']) && isset($_POST['dennam'])){
				$data['listhd']=$obtk->tkhoadon($_POST['tunam'], $_POST['dennam']);
				echo '<script>window.location.href="admin.php?mod=bieudodt"</script>';
			}
			$data['listcthd']=$obtk->listcthd();
			$data['listmh']=$obtk->listmh();
			require_once 'views/admin/thongke/doanhthu.php';
			break;
		}
		case 'bieudodt':{
			$data['listcthd']=$obtk->listcthd();
			$data['listmh']=$obtk->listmh();
			require_once 'views/admin/thongke/bieudodt.php';
			break;
		}
	case 'tkloinhuan':{
			if(isset($_POST['tunam']) && isset($_POST['dennam'])){
				$data['listhd']=$obtk->tkhoadon($_POST['tunam'], $_POST['dennam']);
				echo '<script>window.location.href="admin.php?mod=bieudoln"</script>';
			}
			$data['listcthd']=$obtk->listcthd();
			$data['listmh']=$obtk->listmh();
			$data['listctn']=$obtk->listctnhap();
			require_once 'views/admin/thongke/loinhuan.php';
			break;
		}
		case 'bieudoln':{
			$data['listcthd']=$obtk->listcthd();
			$data['listmh']=$obtk->listmh();
			require_once 'views/admin/thongke/bieudoln.php';
			break;
		}
	}
}